layui.use(['laydate','form','layer','table','common'], function(){
    var laydate = layui.laydate;
    var form = layui.form;
    var $ = layui.$;
    var layer = layui.layer;
    var table = layui.table;
    var common = layui.common;

    /*@配件返库初始化table*/
    var tableObj = table.render({
        elem: '#table-list',
        url: '/printing/printing/index', //数据接口
        id: 'table_list',
        page: true, //开启分页
        cols: [[ //表头
            {field: 'id', title: '序号'},
            {field: 'state_text', title: '打印类型'},
            {field: 'is_show_text', title: '状态'},
            {title: '操作', toolbar: '#table-btn'},
        ]],
        /*渲染前，请求成功后回调*/
        parseData: function(res){
            if(res.code === 0){
                var num = (res.page-1) * res.row
                for(var i = 0;i < res.data.length;++i){
                    res.data[i].id = num + i + 1
                }
                exportData = res.data
            }
        }
    });

    /*@导出数据处理*/
    common.list.handleData = function(res){
        for(var i = 0;i < res.data.length;++i){
            res.data[i].id = i + 1
        }
        return res.data
    }
    /*@查询*/
    common.list.search('search', tableObj)
    /*@导出*/
    common.list.excel('export', '/repair/stock/index', tableObj, '维修返库配件', 'xls')
});